package com.summer.LanQiao;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class _13Jie {
    //已知今天是星期六，请问 20^22 天后是星期几？
    //注意用数字 1 到 7 表示星期一到星期日。
    public static void A(){
        BigDecimal day = new BigDecimal(1);
        BigDecimal yushu = new BigDecimal(7);
        day = day.multiply(new BigDecimal(20).pow(22));
        System.out.println(day.toString());
        BigDecimal[] b = day.divideAndRemainder(yushu);
        System.out.println(b[1].toString());

    }
    public static boolean isSort(int[] arr,int count){
        int leftIndex,rightIndex = 0;
        if (count%2==0) leftIndex = count / 2 -1;
        else leftIndex = count / 2;
        rightIndex = count / 2;
            while (leftIndex >0&&rightIndex<count-1){
                if (arr[leftIndex] < arr[leftIndex-1]||arr[rightIndex] < arr[rightIndex+1]) return false;
                else {
                    leftIndex--;
                    rightIndex++;
                }
            }
            return true;
        }

    public static boolean isHuiWen(long num){
        long oldNum = num;
        int[] nums =new int[10];
        int i = 0;
        while ((num / 10) != 0){
            nums[i++] =(int)num % 10 ;
            num /= 10;
        }
        nums[i] = (int)num % 10;
        long newNum = 0;
        for (int j = 0; j <= i ; j++) {
            newNum += nums[j]*Math.pow(10,i-j);
        }
        if (newNum == oldNum && isSort(nums,i+1)) return true;
        else return false;
    }
    public static int B(){
        int count = 0;
        for (long i = 2022; i <= 2022222022; i++) {
            if (isHuiWen(i)){
                System.out.println(i+"是符合的数字");
                count++;
            }
        }
        return count;
    }
    public static String C(String s){
        int[] charsNum = new int[26];
        char[] chars = s.toCharArray();
        for (int i = 0; i < chars.length ; i++) {
            int charNum = (int)chars[i]-65;
            charsNum[charNum]++;
        }
        int max = 0;
        int Mindex = 0;
        for ( int i = 0; i < charsNum.length ; i++) {
            if (charsNum[i] > max){
                max = charsNum[i];
                Mindex = i;
            }
        }
        char c1 = (char) (Mindex + 65);
        String res = String.valueOf(c1);
        for (int j = 0; j < charsNum.length ; j++) {
                if (charsNum[j] == max && j != Mindex){
                    res += String.valueOf((char) (j + 65));
                }
        }
        return res;
    }
    public static void D() {
        Scanner sc = new Scanner(System.in);
        int StuCount = sc.nextInt();
        int[] QusCount = new int[StuCount];
        for (int i = 0; i < QusCount.length ; i++) {
            QusCount[i] = sc.nextInt();
        }
        System.out.println(Arrays.toString(QusCount));
    }
    public static BigDecimal E(BigDecimal K){
        BigDecimal b = new BigDecimal("1");
        BigDecimal N = new BigDecimal("1");
        BigDecimal ad = new BigDecimal("1");
        BigDecimal countZ =new BigDecimal("1") ;
       countZ = countZ.multiply(new BigDecimal("10").pow(19));
        while (true){
            String s = N.toBigInteger().toString();
            BigDecimal count =new BigDecimal("0") ;
            int index = s.length()-1;
            while (index >=0&&s.charAt(index)=='0'){
                count = count.add(new BigDecimal("1"));
                index--;
            }
            if (count.compareTo(countZ)==1) return new BigDecimal("-1");
            if (count.compareTo(K) == 0) break;
          N = N.multiply(b.add(ad));
          b = b.add(ad);
        }
        return b;
    }
    public static void main(String[] args) {
        //A();
        //System.out.println(B());
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
//        String s = sc.nextLine();
//        System.out.println(C(s));
        BigDecimal K = new BigDecimal(s);
        System.out.println(E(K));

    }
}
